<template>
  <div class="home">
    <p>欢迎登录，{{ user }}</p>
    <button @click="loginout">退出登录</button>
  </div>
</template>

<script>
export default {
  name: "Home",
  components: {},
  data() {
    return {
      user: localStorage.getItem("user"),
    };
  },
  methods: {
    loginout() {
      let bool = confirm("确定要退出吗？");
      if (bool) {
        localStorage.removeItem("user");
        this.$router.push("/login");
      }
    },
  },
};
</script>
